package com.explorex.infra.puma.gateway.netty.ws;

import com.explorex.infra.puma.gateway.netty.common.AbstractBaseServer;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.HttpHeaders;

import java.security.NoSuchAlgorithmException;
import java.util.Map;

/**
 * @author: JacceYang
 * @createTime: 2022/07/14 9:19 下午
 * @description: WebSocketEvent handler
 */

public interface WebSocketEvent {
    /**
     * onOpenEvent
     *
     * @param server
     * @param session
     * @param parameter
     */
    void onOpenEvent(AbstractBaseServer server, WebSocketSession session, HttpHeaders httpHeaders, Map<String, Object> parameter) throws NoSuchAlgorithmException;

    /**
     * onCloseEvent
     *
     * @param server
     * @param session
     */
    void onCloseEvent(AbstractBaseServer server, WebSocketSession session);

    /**
     * on Error Event
     *
     * @param session
     */
    void OnErrorEvent(WebSocketSession session);

    /**
     * onMessageStringEvent
     *
     * @param server
     * @param session
     * @param msg
     */
    void onMessageStringEvent(AbstractBaseServer server, WebSocketSession session, String msg);

    /**
     * onMessageBinaryEvent
     *
     * @param server
     * @param session
     * @param msg
     */
    void onMessageBinaryEvent(AbstractBaseServer server, WebSocketSession session, ByteBuf msg);
}

